package edu.um.automata;

import edu.um.token.TokenKind;

public class Transition {

  private final TokenKind tokenKind;

  private final StackSymbol stackSymbolReceived;

  private final StackSymbol stackSymbolPut1;

  private final StackSymbol stackSymbolPut2;

  public Transition(TokenKind tokenKind, StackSymbol stackSymbolReceived) {
    this(tokenKind, stackSymbolReceived, null);
  }

  public Transition(TokenKind tokenKind, StackSymbol stackSymbolReceived,
      StackSymbol stackSymbolPut1) {
    this(tokenKind, stackSymbolReceived, stackSymbolPut1, null);
  }

  public Transition(TokenKind tokenKind, StackSymbol stackSymbolReceived,
      StackSymbol stackSymbolPut1, StackSymbol stackSymbolPut2) {
    super();
    this.tokenKind = tokenKind;
    this.stackSymbolReceived = stackSymbolReceived;
    this.stackSymbolPut1 = stackSymbolPut1;
    this.stackSymbolPut2 = stackSymbolPut2;
  }

  public Transition(TokenKind tokenKind) {
    this(tokenKind, null);
  }

  public TokenKind getTokenKind() {
    return tokenKind;
  }

  public StackSymbol getStackSymbolReceived() {
    return stackSymbolReceived;
  }

  public StackSymbol getStackSymbolPut1() {
    return stackSymbolPut1;
  }

  public StackSymbol getStackSymbolPut2() {
    return stackSymbolPut2;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj instanceof Transition) {
      Transition transition = (Transition) obj;
      return (this.tokenKind == transition.tokenKind && this.stackSymbolReceived == transition.stackSymbolReceived);
    }
    return false;
  }

  @Override
  public String toString(){
    return this.getTokenKind() + "::" + this.getStackSymbolReceived();
  }

}
